// 音乐开始
var audio = document.getElementById('audio')

audio.oncanplay = function(){
    $('.music-kaihsi').html(times(audio.currentTime));
    $('.music-zong').html(times(audio.duration));
    $('.btn').click (function (){

        
        if(audio.paused){
            audio.play();
            $('.btn>span:first-child').css('display','none');
            $('.btn>span:last-child').css('display','block');
        }else{
            audio.pause()
            $('.btn>span:first-child').css('display','block');
            $('.btn>span:last-child').css('display','none');
        }
    })
}
audio.ontimeupdate = function(){
    $('.music-kaihsi').html(times(audio.currentTime));
    $('.music-zong').html(times(audio.duration));
    var jindu = ((audio.currentTime/audio.duration)*100).toFixed(2)+"%";
    $('.music-jindu1>div').width(jindu);
    if(audio.ended){
        $('.btn>span:first-child').css('display','block');
        $('.btn>span:last-child').css('display','none');
        $('.music-jindu1>div').width(0);
        $('.music-kaihsi').html('00:00');
    }

}
$.ajax({
    type:'get',
    url:'http://iwenwiki.com/api/blueberrypai/getSongInfo.php',
    data:{
        song:'mo'
    },
    success:function(res){

        var songInfo = res.songInfo;
        $('.music-title>p:first-child').text(songInfo.song_title);
        $('.music-title>p:last-child>span:first-child').text(songInfo.play_num);
        $('.music-title>p:last-child>span:first-child').text(songInfo.play_num);
        $('.music-img>img').attr('src','http://iwenwiki.com/api/blueberrypai/'+songInfo.song_pic);
        $('.music-img>p').html(songInfo.song_intro_cont);
    }


})



function times(num){
    var m = parseInt(num/60);
    var s = parseInt(num%60);
    m = m>9?m:"0"+m;
    s = s>9?s:"0"+s;
    return m+":"+s;
}
// 音乐结束
// 文章开始
$.ajax({
    type:'get',
    url:'http://iwenwiki.com/api/blueberrypai/getInterestingInfo.php',
    success:function(res){
        var str = res.interestingInfo;
        $(".wenzhang-box1>h3").html(str.interest_title)
        
        $('.liulan-1').html(str.eye_num);
        $('.liulan-2').html(str.wei_chat_num);
        $('.liulan-time>span').html(str.interest_create_time);
        var str1 = str.interest_cont;
        var arr = str1.split('\r\n');
        var str1 = arr.join('</br>');
        $('.wenzhang-zi').html(str1);

        // 提取标签
        var arr = res.labels;
        var str2 = '';
        for(var i = 0;i<arr.length;i++){
            str2+='<span>'+arr[i]+'</span>';
        }
        $('.xingqu').append(str2);
        
        // 相关阅读内容
        var arr2 = res.related_read;
        console.log(arr2);
        for(var j = 0;j<arr2.length;j++){
            $('.yuedu-box').append(`<div>
            <img src="http://iwenwiki.com/api/blueberrypai/${arr2[j].related_read_pic}" alt="">
            <p>${arr2[j].related_read_summary}</p>
        </div>`);
        }




    }
})



// 文章结束